home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Disk / PowerScan 2.0 / PP⁄Filter Defs.p < prev    next >
Text File  |  1993-09-24  |  11KB  |  254 lines

  1. unit pp_filter_defs;
  2. interface
  3.  
  4.  
  5.  
  6.     const
  7.         {--misc. constants--}
  8.         kDontDisableItem = 16384; {add this constant to avoid InstallDITLItem to disable a user item}
  9.  
  10.         {--file types and creators--}
  11.         kPreprocessorAddinFileType = 'PScP';
  12.         kFilterAddinFileType = 'PScF';
  13.  
  14.         {--preprocessor addins constants--}
  15.         kPPParamVersion = $0001; {version 1 of PP API}
  16.         kPPAddinResType = 'PScP'; {resource type for preprocessor addin}
  17.         kPPAddinResID = 128; {resource ID for preprocessor addin code}
  18.         kPPAddinInfoResType = 'PSpi'; {resource type for preprocessor info}
  19.         kPPAddinInfoResID = 128; {resource ID for preprocessor info}
  20.         kPPAddinInfoStringResType = 'STR '; {resource type for preprocessor info string}
  21.         kPPAddinInfoStringResID = 128; {resource ID for preprocessor info string}
  22.         kPPUnusedTypes = '    '; {type that is unused by the preprocessor}
  23.         kPPMatchAnyType = '****'; {type code that preprocessor can use to match any file}
  24.  
  25.         {--selector codes for filter addin--}
  26.         kPPAddinLoad = 1; {open preprocessor first time [application launch]}
  27.         kPPAddinPreprocessFile = 2; {preprocess file}
  28.         kPPAddinCleanup = 3; {cleanup before closing preprocessor [application exit]}
  29.  
  30.         {--filter addins constants--}
  31.         kFilterParamVersion = $0001; {version 1 of filter API}
  32.         kFilterAddinResType = 'PScF'; {resource type for filter addin}
  33.         kFilterAddinResID = 128; {resource ID for filter addin code}
  34.         kFilterAddinInfoResType = 'PSfi'; {resource type for filter info}
  35.         kFilterAddinInfoResID = 128; {resource ID for filter info}
  36.         kCallbackBlockVersion = $0001; {first version of callback block}
  37.  
  38.         {--selector codes for filter addin--}
  39.         kFilterAddinLoad = 1; {open filter first time [application launch]}
  40.         kFilterAddinDefaultSettings = 2; {fill in settings with default values}
  41.         kFilterAddinSettingsDialog = 3; {show dialog [instance-specific]}
  42.         kFilterAddinPrepareForFiltering = 4; {init filter before filtering [instance-specific]}
  43.         kFilterAddinFilterFile = 5; {filter file [instance-specific]}
  44.         kFilterAddinFilteringFinished = 6; {cleanup after filtering [instance-specific]}
  45.         kFilterAddinCleanup = 7; {cleanup before closing filter [application exit]}
  46.  
  47.         {--variant parts of tFileInfo record--}
  48.         kFileInfoVariant = 3;
  49.  
  50.  
  51.  
  52.     type
  53.         tStr10 = string[10];
  54.         tStr15 = string[15];
  55.         tStr20 = string[20];
  56.         tStr31 = string[31];
  57.         tStr63 = string[63];
  58.         tStr63Ptr = ^tStr63;
  59.         tStr100 = string[100];
  60.  
  61.         {--block with callback routines for external filter code--}
  62.         tMyCallbackBlock = record
  63.                 cbVersion: integer; {version for the callback block}
  64.                 cbCenterWindow: procPtr; {(theWindow, sameScreenAsWin: windowPtr; showIt: boolean)}
  65.                 cbMyDisposeDialog: procPtr; {(theDialog:dialogPtr)}
  66.                 cbInstallDITLItem: procPtr; {(dP: dialogPtr; itemNo: integer; proc: procPtr; expandItemRect: boolean)}
  67.                 cbFrameButtonRect: procPtr; {(theD: dialogPtr; itemNo: integer)}
  68.                 cbInstallPopupUserItem: procPtr; {(theD: dialogPtr; item: integer; theMenu: menuHandle; selectedItem: integer)}
  69.                 cbPopupItemSelected: procPtr; {(theD: dialogPtr; item: integer): integer}
  70.                 cbReleaseDialogItemData: procPtr; {(theD: dialogPtr)}
  71.                 cbHandlePopupMenu: procPtr; {(theD: dialogPtr; item: integer)}
  72.                 cbMyModalDialogFilter: procPtr; {(theD: dialogPtr; var e: eventRecord; var itemHit: integer): boolean}
  73.                 cbSetDialogItemData: procPtr; {(theD: dialogPtr; item: integer; data1, data2: longint)}
  74.             end;
  75.         tMyCallbackBlockPtr = ^tMyCallbackBlock;
  76.  
  77.  
  78.     {Define array used to store additional data for an item in a dialog box; used so we can extract the procPtr for the}
  79.     {callback routine of e.g. an user item update procedure without using globals in our code resource and without nesting}
  80.     {the routine which isn’t possbile due to Pascal’s handling of the @ operator}
  81.  
  82.         tDialogItemDataRecord = record
  83.                 itemData1, itemData2: longint;
  84.             end;
  85.         tDialogItemDataArray = array[1..1] of tDialogItemDataRecord;
  86.         tDialogItemDataPtr = ^tDialogItemDataArray;
  87.  
  88.         {--scan preprocessors--}
  89.         tInterestingTypesArray = array[1..8] of OSType; {'****' for any file; '    ' for unused}
  90.         tInterestingTypesPtr = ^tInterestingTypesArray;
  91.         tPPAddinType = record
  92.                 longName: tStr63; {full name of preprocessor}
  93.                 uniqueType: OSType; {four chars that uniquely identify this preprocessor}
  94.                 paramVersion: integer; {what version of the API is this preprocessor compatible with?}
  95.                 filler1: integer;
  96.  
  97.                 refCon: longint; {field owned by the preprocessor}
  98.                 resForkRefNum: integer; {refnumber for resource fork of this addin}
  99.                 enabledFlag: boolean; {is this filter enabled?}
  100.                 filler2: boolean;
  101.                 preprocessorIconSuiteID: integer; {resource id of icon suite}
  102.                 preprocessorEntryProc: procPtr; {entrypoint for preprocessor code}
  103.  
  104.                 interestingFileTypes: tInterestingTypesArray; {what filetypes are this filter interested in?}
  105.             end;
  106.         tPPAddinPtr = ^tPPAddinType;
  107.  
  108.         {--filter addins--}
  109.         tFilterAddinType = record
  110.                 longName: tStr63; {full name of filter}
  111.                 shortName: tStr15; {short name of addin as listed in Edit File Filters dialog box}
  112.                 uniqueType: OSType; {four chars that uniquely identify this filter}
  113.                 paramVersion: integer; {what version of the API is this filter compatible with?}
  114.                 filler1: integer;
  115.  
  116.                 refCon: longint; {field owned by the addin [shared among all instances]}
  117.                 resForkRefNum: integer; {refnumber for resource fork of this addin}
  118.                 filterIconSuiteID: integer; {resource ID for filter icon suite}
  119.                 filterIconSuite: handle; {handle to icon suite}
  120.                 filterEntryProc: procPtr; {entrypoint for filter code}
  121.                 hasSettingsDialog: boolean; {flag if this filter has any settings dialog box}
  122.                 filler2: boolean;
  123.             end;
  124.         tFilterAddinPtr = ^tFilterAddinType;
  125.  
  126.         {--directory entry for a file or folder--}
  127.         tDelimiterType = (fileDelimiter, scanDelimiter); {different types of delimiting lines}
  128.         tIconType = (iconApplication, iconArchiveApplication, iconDocument, iconArchiveDocument, iconFolder, iconArchiveFolder, noIcon);
  129.         tTextStrType = tStr100; {type of string for text string rows}
  130.         tFileInfo = record
  131.                 case fileInfoVariant : integer of
  132.                     kFileInfoVariant: (
  133.                             fileName: tStr31;
  134.                             dirID: longint;
  135.                             vRefNum: integer; {this field is used as an index in the volume alias array as soon as the scanning is completed}
  136.  
  137.                             iconType: tIconType; {what kind of icon should we use and is this file really an existing file (not inside an archive)?}
  138.                             isAlias: boolean; {is this an alias?}
  139.                             fileFlags: integer; {attribute flags from file info; 0 for folders}
  140.                             indentLevel: integer; {how many levels should we indent this filename?}
  141.                             fileSize: longint;
  142.                             crDate, mdDate: longint;
  143.                             fileType, fileCreator: OSType;
  144.                             fileVersion: numVersion; {version info}
  145.                             crDateStr, mdDateStr: tStr20; {dates converted to strings}
  146.                             selected: boolean; {is this row highlighted?}
  147.                             indexInFolder: integer; {indicates the number of rows one must step back to come to parent folder; used for creating pathnames quickly through backtracing}
  148.                             internalFlag: boolean; {used e.g. when copying records after filtering}
  149.                     )
  150.             end;
  151.         tFileInfoPtr = ^tFileInfo;
  152.  
  153.         {--record used when preprocessing an archive that contain multiple files--}
  154.         tArchiveScanRecord = record
  155.                 fileIndex: integer; {index of the file that should be returned from the archive; pp increases this value}
  156.                 refCon: longint; {owned by the preprocessor while an archive is scanned}
  157.             end;
  158.         tArchiveScanPtr = ^tArchiveScanRecord;
  159.  
  160.  
  161.  
  162.     procedure extractDialogItemData (theD: dialogPtr; item: integer; var data1, data2: longint);
  163.     procedure cbCenterWindow (theWindow, sameScreenAsWin: windowPtr; showIt: boolean; theAddr: procPtr);
  164.     inline
  165.         $205f, $4e90;
  166.     procedure cbMyDisposeDialog (theDialog: dialogPtr; theAddr: procPtr);
  167.     inline
  168.         $205f, $4e90;
  169.     procedure cbInstallDITLItem (dP: dialogPtr; itemNo: integer; proc: procPtr; expandItemRect: boolean; theAddr: procPtr);
  170.     inline
  171.         $205f, $4e90;
  172.     procedure cbFrameButtonRect (theD: dialogPtr; itemNo: integer);
  173.     procedure cbInstallPopupUserItem (theD: dialogPtr; item: integer; theMenu: menuHandle; selectedItem: integer; theAddr: procPtr);
  174.     inline
  175.         $205f, $4e90;
  176.     function cbPopupItemSelected (theD: dialogPtr; item: integer; theAddr: procPtr): integer;
  177.     inline
  178.         $205f, $4e90;
  179.     procedure cbReleaseDialogItemData (theD: dialogPtr; theAddr: procPtr);
  180.     inline
  181.         $205f, $4e90;
  182.     procedure cbHandlePopupMenu (theD: dialogPtr; item: integer; theAddr: procPtr);
  183.     inline
  184.         $205f, $4e90;
  185.     function cbMyModalDialogFilter (theD: dialogPtr; var e: eventRecord; var itemHit: integer): boolean;
  186.     procedure cbSetDialogItemData (theD: dialogPtr; item: integer; data1, data2: longint; theAddr: procPtr);
  187.     inline
  188.         $205f, $4e90;
  189.  
  190.  
  191. implementation
  192.  
  193.  
  194. {==========================================================================================}
  195. {  C A L L B A C K   S E C T I O N   }
  196. {==========================================================================================}
  197.  
  198.  
  199. {extractDialogItemData returns info for a specific item in a dialog; it is a hack to circumvent the problem that a userItem}
  200. {can’t have any additional parameters except for dialog pointer and item number}
  201.     procedure extractDialogItemData (theD: dialogPtr; item: integer; var data1, data2: longint);
  202.         var
  203.             myDialogItemDataPtr: tDialogItemDataPtr;
  204.     begin
  205.         {--get pointer to array of items for this dialog--}
  206.         myDialogItemDataPtr := tDialogItemDataPtr(getWRefCon(theD));
  207.  
  208.         {--make sure we have a valid pointer before dereferencing--}
  209.         if myDialogItemDataPtr <> nil then
  210.             with myDialogItemDataPtr^[item] do
  211.                 begin {--myDialogItemDataPtr<>nil--}
  212.                     {--return data from array--}
  213.                     data1 := itemData1;
  214.                     data2 := itemData2;
  215.                 end {--myDialogItemDataPtr<>nil; with myDialogItemDataPtr^[item]--}
  216.         else
  217.             begin {--myDialogItemDataPtr=nil--}
  218.                 data1 := 0;
  219.                 data2 := 0;
  220.             end; {--myDialogItemDataPtr=nil--}
  221.     end;
  222.  
  223.     procedure cbFrameButtonRectInline (theD: dialogPtr; itemNo: integer; theAddr: procPtr);
  224.     inline
  225.         $205f, $4e90;
  226.     procedure cbFrameButtonRect (theD: dialogPtr; itemNo: integer);
  227.         var
  228.             data1, data2: longint;
  229.     begin
  230.         {--extract callback address from this item’s external data array--}
  231.         extractDialogItemData(theD, itemNo, data1, data2);
  232.  
  233.         {--now call the callback routine--}
  234.         cbFrameButtonRectInline(theD, itemNo, procPtr(data1));
  235.     end;
  236.  
  237.     function cbMyModalDialogFilterInline (theD: dialogPtr; var e: eventRecord; var itemHit: integer; theAddr: procPtr): boolean;
  238.     inline
  239.         $205f, $4e90;
  240.     function cbMyModalDialogFilter (theD: dialogPtr; var e: eventRecord; var itemHit: integer): boolean;
  241.         var
  242.             data1, data2: longint;
  243.     begin
  244.         {--extract callback address from dialog’s external data array; this address should be at the first item’s position--}
  245.         extractDialogItemData(theD, 1, data1, data2);
  246.  
  247.         {--now call the callback routine--}
  248.         cbMyModalDialogFilter := cbMyModalDialogFilterInline(theD, e, itemHit, procPtr(data1));
  249.     end;
  250.  
  251. {==========================================================================================}
  252.  
  253.  
  254. end.